package cn.melonlib.graphql.exceptions;

import graphql.schema.DataFetchingEnvironment;
import lombok.Getter;

import java.lang.reflect.Method;
import java.util.List;

@Getter
public class GraphqlExecuteException extends Exception{

    private final Object bean;

    private final Method method;

    private final List<? extends Object> params;

    private final DataFetchingEnvironment environment;

    public GraphqlExecuteException(Object bean, Method method, List<? extends Object> params, DataFetchingEnvironment environment) {
        this.bean = bean;
        this.method = method;
        this.params = params;
        this.environment = environment;
    }

    public GraphqlExecuteException(String message, Object bean, Method method, List<? extends Object> params, DataFetchingEnvironment environment) {
        super(message);
        this.bean = bean;
        this.method = method;
        this.params = params;
        this.environment = environment;
    }

    public GraphqlExecuteException(String message, Throwable cause, Object bean, Method method, List<? extends Object> params, DataFetchingEnvironment environment) {
        super(message, cause);
        this.bean = bean;
        this.method = method;
        this.params = params;
        this.environment = environment;
    }

    public GraphqlExecuteException(Throwable cause, Object bean, Method method, List<? extends Object> params, DataFetchingEnvironment environment) {
        super(cause);
        this.bean = bean;
        this.method = method;
        this.params = params;
        this.environment = environment;
    }

    public GraphqlExecuteException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Object bean, Method method, List<? extends Object> params, DataFetchingEnvironment environment) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.bean = bean;
        this.method = method;
        this.params = params;
        this.environment = environment;
    }
}
